package com.tedu.bill.demo1;

/**
 * Author：毕龙
 * Date: 2024/5/17 15:53
 */
public class JSONResult2<T>{
    private  T data;
    private  String message;
    private  Integer state;

    public JSONResult2() {
    }

    public JSONResult2(T data, ResponseState responseState) {
        this.data = data;
        this.message = responseState.getMessage();
        this.state = responseState.getCode();
    }
    //om.tedu.bill.demo1.JSONResult2.this' cannot be referenced from a static context
    //在方法中添加<T> 在静态代码块中可以使用泛型
    public static <T> JSONResult2 ok(T data){
        return new JSONResult2(data, ResponseState.RESPONSE_OK);
    }

    public static <T> JSONResult2 fail(){
        return new JSONResult2(null, ResponseState.RESPONSE_FAIL);
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }
}
